package com.tensquare.user.utils;

import com.tensquare.constants.TokenConstants;
import com.tensquare.entity.JWTInfo;
import com.tensquare.exception.UserTokenException;
import com.tensquare.util.RedisConstant;
import com.tensquare.util.StringHelper;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;

public class JWTUtil {

    /**
     * 获取用户JWT的信息
     */
    public JWTInfo getJWTInfo(Claims infoFromToken) {
        return new JWTInfo(StringHelper.getObjectValue(infoFromToken.get(TokenConstants.JWT_KEY_USER_ACCOUNT)),
                StringHelper.getObjectValue(infoFromToken.get(TokenConstants.JWT_KEY_NICKNAME)),
                StringHelper.getObjectValue(infoFromToken.get(TokenConstants.JWT_KEY_id)));
    }
}
